<script type="text/javascript">
$(function(){	
	var pg = App.soagov.macRpcSvcIp.ui, pp = pg.params,
		tabs = pg.find('.tabs'),
		refGd = pg.seek('refGd'),
		svcGd = pg.seek('svcGd'),
		hd = pg.children('.head'),
		title = hd.seek('title');
	
	title.text(pp.reg);
			
	function init(o) {
		data = o;
		var l = [], d = o.reg, r = [];
		for (var k in d) {
			for(var a in d[k].referenceMap){
				if(d[k].referenceMap[a].name == pp.reg){
					l.push(d[k]);
				}
			}
			for(var b in d[k].serviceMap){
				if(d[k].serviceMap[b].name == pp.reg){
					r.push(d[k]);
				}
			}
		}
		if (l.length) {
			refGd.loadData(l);
		}
		if (r.length) {
			svcGd.loadData(r);
		}
	}
		
	//填充tabs
	tabs.mac('tabs', {
		tabWidth: 80,
		tabHeight: 32,
		items: [{
			code: 'refPl', title: '提供者', el: refGd
		}, {
			code: 'svcPl', title: '消费者', el: svcGd
		}],
	}).selectFirst(); 
		
	//提供者
	refGd.mac('grid', {
		cols : [{
			field: 'key', title : 'IP地址', width: 180
		},{
			field: 'version', title : '上次更新时间', width: 180,
			render: function(r){
				return new Date(r.version.time).format('yyyy-MM-dd HH:mm:ss.S');
			}
		}],
		pagerLength: 1000
	});
	
	//消费者
	svcGd.mac('grid', {
		cols : [{
			field: 'key', title : 'IP地址', width: 180
		},{
			field: 'version', title : '上次更新时间', width: 180,
			render: function(r){
				return new Date(r.version.time).format('yyyy-MM-dd HH:mm:ss.S');
			}
		}],
		pagerLength: 1000
	});

	function adjust(){
		var h = pg.parent().height();
		pg.height(h);
		tabs.height(h - hd.height() - 8);
		tabs.adjust();
		h = tabs.children('.body').height();
		refGd.parent().height(h - 5);
		refGd.adjust();
		svcGd.parent().height(h);
		svcGd.adjust();
	}
	$(window).resize(adjust);
	adjust();

	if (pp) {
		init(pp.all);
	}
});
</script>
<div class="head">
	<div class="title">
		当前服务:<span  name="title">XXXX</span>
	</div>
</div>
<div class="tabs"></div>
<div class="grid" name="refGd"></div>
<div class="grid" name="svcGd"></div>
